package com.devframe.web.taglib;

import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

import com.devframe.sysbase.loader.SysBaseContainer;

import net.sf.json.JSONObject;


/**
 * 
 * <pre>
 * &lt;b&gt;&lt;font color=&quot;blue&quot;&gt;SelectTag&lt;/font&gt;&lt;/b&gt;
 * </pre>
 * 
 * <pre>
 * &lt;b&gt; --系统参数输出标签--&lt;/b&gt;
 * </pre>
 * <pre>
 * 用于显示系统名称等可配置的系统参数项
 * </pre>
 * <pre>
 * &lt;b&gt;--样例--&lt;/b&gt;
 * 实例1：代码名称翻译
 *   <d:sysParam value="APP"/>
 * </pre>
 * 
 * JDK版本：JDK1.4
 * 
 * 
 */
public class SysParameterTag extends AbstractBaseTag {
    /**
     * serialVersionUID
     */
    private static final long serialVersionUID = 932991928216241306L;

    /**
     * 参数名，支持EL
     */
    private String paramName; // 


    /**
     * @return SKIP_BODY
     */
    public int doStartTag() {
        return SKIP_BODY;
    }

    /**
     * doEndTag
     * 标签处理逻辑，根据代码显示名称
     * @return EVAL_PAGE
     * @throws JspException
     *             JspException
     */
    public int doEndTag() throws JspException {
		try {
			JspWriter writer = null;
			try {
				writer = this.getPreviousOut();
			} catch (Exception e1) {
				writer = pageContext.getOut();
			}
            String paramValue = paramName;
            try {
                paramValue = SysBaseContainer.accessCacheDataHandle().getSysParam(paramName);
            } catch (RuntimeException e1) {
                e1.printStackTrace();
            }
            try {
                writer.print(paramValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
			return EVAL_PAGE;
		} catch (Exception e) {
			return EVAL_PAGE;
		}
	}

    /**
     * release
     * 
     * @see javax.servlet.jsp.tagext.BodyTagSupport#release()
     */
    public void release() {
        super.release();
    }

    public String getParamName() {
        return paramName;
    }

    public void setParamName(String paramName) {
        this.paramName = paramName;
    }


}
